<!DOCTYPE HTML>
<html>
<head>
    <meta charset="utf-8">
    <meta name="renderer" content="webkit|ie-comp|ie-stand">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no" />
    <meta http-equiv="Cache-Control" content="no-siteapp" />
    <link rel="stylesheet" type="text/css" href="__CSS__/main.css" />
    <link rel="stylesheet" type="text/css" href="__CSS__/common.css" />
    <link rel="stylesheet" type="text/css" href="__CSS__/bootstrap.min.css" />
    <script type="text/javascript" src="__EXTEND__/lib/jquery/1.9.1/jquery.min.js"></script>
    <script type="text/javascript" src="__EXTEND__/js/bootstrap.min.js"></script>
    <script type="text/javascript" src="__EXTEND__/lib/layer/2.4/layer.js"></script>
    <![endif]-->
    <title>设置权限</title>
</head>
<body>
<div class="contant">
<div class="row"><h3 class="page-header">设置权限</h3></div>
<div class="row">
    <div class="col-md-12">
        <div class="panel panel-default">
            <div class="panel-body">
            	<button class="btn btn-default all m-b-5" type="button">全选</button>
	            <button class="btn btn-default contrary m-b-5" type="button">反选</button>
            	<form id="myform">
	                <div class="table-responsive">
	                    <table class="table table-striped table-bordered table-hover">
	                        <thead>
	                        	<tr>
	                           		<th width="60"></th>
	                                <th>节点名称</th>
	                                <th>节点路径</th>
	                            </tr>
	                        </thead>
	                        <tbody>
	                            <volist name="list" id="list">
		                            <tr class="level{$list.pid} <gt name='list.pid' value='0'> hide</gt>"  >
		                                <td><i data-id="{$list.id}" data-open='1' class="fa fa-plus open"></i></td>
		                                <td>
		                                 	<switch name='list.type'>
			                                 	<case value="0">&nbsp;|-&nbsp;&nbsp;&nbsp;</case>
			                                 	<case value="1">&nbsp;|&nbsp;&nbsp;&nbsp;|-&nbsp;&nbsp;&nbsp;</case>
			                                 	<case value="2">&nbsp;|&nbsp;&nbsp;&nbsp;|&nbsp;&nbsp;&nbsp;|-&nbsp;&nbsp;&nbsp;</case>
		                                 	</switch>
		                                 	<label class="checkbox-inline">
						                    	<input id="level{$list.id}" data-id="{$list.id}" type="checkbox" name="rule[]" value="{$list['id']}" <?php if(in_array($list['id'], $info['rules'])){ echo checked;} ?> >
						                    </label>
		                                 	<label for="level{$list.id}">{$list.title}</label>
		                                </td>
		                                <td>
			                                <switch name='list.type'>
				                                <case value="0">&nbsp;|-&nbsp;&nbsp;&nbsp;</case>
				                                <case value="1">&nbsp;|&nbsp;&nbsp;&nbsp;|-&nbsp;&nbsp;&nbsp;</case>
				                                <case value="2">&nbsp;|&nbsp;&nbsp;&nbsp;|&nbsp;&nbsp;&nbsp;|-&nbsp;&nbsp;&nbsp;</case>
			                                </switch>{$list.name}
		                                </td>
		                            </tr>
	                            </volist>
	                        </tbody>
	                    </table>
	                </div>
	                <div class="form-group">
	                    <div class="col-sm-offset-3 col-sm-5">
					        <button class="btn btn-primary" type="submit">提交</button>
					        <input type="hidden" name="id" value="{$_GET['id']}">
					       	<a href="{:U('Group/index')}"><button class=" btn btn-default" type="button">返回</button></a>
						</div>
					</div>
                </form>
            </div>
        </div>
    </div>
</div>
</div>
<script type="text/javascript">
	$(function(){
		$('.open').click(function(){
			if($(this).data('open') == 0){
				$(this).removeClass('fa-minus').addClass('fa-plus');
				$('.level'+$(this).data('id')).addClass('hide');
			}else{
				$(this).removeClass('fa-plus').addClass('fa-minus');
				$('.level'+$(this).data('id')).removeClass('hide');
			}
			$(this).data('open', $(this).data('open') == 1 ? 0 : 1);
		});
		$('.all').click(function(){
			$("input[type='checkbox']").attr("checked", true);
		});
		$('.contrary').click(function(){
			$("input[type='checkbox']").each(function () {   
		        $(this).attr("checked", !$(this).attr("checked"));   
		    }); 
		});
		$('input[type="checkbox"]').change(function(){
			var id = $(this).data('id'), chk = $(this).is(':checked');
			$('.level' + id).find('input').attr('checked', chk);
			$('.level' + id).find('input').each(function(i, v){
				$('.level' + $(v).data('id')).find('input').attr('checked', chk);
			});
		});
	})
</script>
</body>
</html>